//
//  UICollectionView+MCRegisterCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2021/5/24.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "UICollectionView+MCRegisterCell.h"

@implementation UICollectionView (MCRegisterCell)

- (void)mc_registerCellByFiterModels:(NSArray<GDFiterCellModel *> *)models {
    for (GDFiterCellModel *model in models) {
        
        if (model.cellDisplayType == GDCellDisplayNone) {
            continue;
        }
        
        if (model.registType == GDFiterCellRegisterByClass) {
            [self registerClass:model.cellKlass forCellWithReuseIdentifier:NSStringFromClass(model.cellKlass)];
        }else if (model.registType == GDFiterCellRegisterByXib) {
            [self registerNib:[UINib nibWithNibName:NSStringFromClass(model.cellKlass) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass(model.cellKlass)];
        }
    }
}

- (void)mc_registerCellClasses:(NSArray<Class> *)classes {
    for (Class class in classes) {
        [self registerClass:class forCellWithReuseIdentifier:NSStringFromClass(class)];
    }
}

- (MCCollectionBaseCell *)mc_dequeueReusableCellWithClassType:(Class)classType forIndexPath:(NSIndexPath *)indexPath{
    return (MCCollectionBaseCell *)[self dequeueReusableCellWithReuseIdentifier:NSStringFromClass(classType) forIndexPath:indexPath];
}

- (MCCollectionBaseCell *)mc_dequeueReusableCellWithFiterModel:(GDFiterCellModel *)model forIndexPath:(NSIndexPath *)indexPath {
    MCCollectionBaseCell *cell = (MCCollectionBaseCell *)[self dequeueReusableCellWithReuseIdentifier:model.cellId forIndexPath:indexPath];
    return cell;
}

@end
